<template>
  <div>
    <el-header>
      <el-row>
        <el-col :span="4" class="logo">
          <el-link href="https://element.eleme.cn/#/zh-CN/component/link">Logo</el-link>
        </el-col>
        <el-col :span="4">
        <el-switch
  v-model="isCollapse"
  active-color="#13ce66"
  inactive-color="#ff4949">
</el-switch>
        </el-col>
        <el-col :span="12">
          <el-menu
            :default-active="activeIndex"
            class="el-menu-demo"
            mode="horizontal"
            @select="handleSelect"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <el-menu-item v-for="item in  nav" :key="item" :index="item">{{item}}</el-menu-item>
          </el-menu>

  
          </el-col>
        <el-col :span="4">
                      <el-dropdown size="mini" type="primary" trigger="click">
  超小尺寸
  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item icon="el-icon-plus">黄金糕</el-dropdown-item>
    <el-dropdown-item icon="el-icon-plus">狮子头</el-dropdown-item>
    <el-dropdown-item icon="el-icon-plus">螺蛳粉</el-dropdown-item>
    <el-dropdown-item icon="el-icon-plus">双皮奶</el-dropdown-item>
    <el-dropdown-item icon="el-icon-plus">蚵仔煎</el-dropdown-item>
  </el-dropdown-menu>
</el-dropdown>
        </el-col>
      </el-row>
    </el-header>
    <el-row>
      <el-col :span="4">
        <el-menu
          mode="vertical"
          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          text-color="#fff"
          active-text-color="#ffd04b"
          background-color="#545c64" 
          :collapse="isCollapse"
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>导航一</span>
            </template>
            <el-menu-item-group>
              <template slot="title">分组一</template>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-2">选项2</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分组2">
              <el-menu-item index="1-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="1-4">
              <template slot="title">选项4</template>
              <el-menu-item index="1-4-1">选项1</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">导航二</span>
          </el-menu-item>
          <el-menu-item index="3" disabled>
            <i class="el-icon-document"></i>
            <span slot="title">导航三</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">导航四</span>
          </el-menu-item>
        </el-menu>
      </el-col>
      <el-col :span="20">
        <component v-if="isShow" :is="activeIndex"></component>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import Components from "@/components/";
export default {
  name: "home",
  components: Components,
  data() {
    return {
      isCollapse:true,
      isShow: true,
      activeIndex: "",
      nav: []
    };
  },
  methods: {
    odAdd() {
      arguments[0];
    },
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
      // if (key == "Theme") {
      //   this.$confirm("确认要进入主题控制吗？")
      //     .then(_ => {
      //       this.activeIndex = key;
      //     })
      //     .catch(_ => {});
      // } else {
      //   this.activeIndex = key;
      // }
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  },

  mounted() {
    let arr = [];
    for (let i in Components) {
      arr.push(i);
    }
    this.nav = arr;
    this.activeIndex = arr[0];
  }
};
</script>
<style scoped lang="scss">
.el-header{
  background-color: #545c64;
  .logo{
    height: 60px;
  }
  .el-link{
    font-size: 30px;
    line-height: 60px;
    color: #fff;
    padding-left: 20px;
    display: block;
    height: 100%;
  }
}
</style>
